package com.projectName.www.service;


import com.projectName.www.util.String_util;
import com.projectName.www.dao.Y_J_orders_dao;

import javax.swing.*;
import javax.swing.GroupLayout.Alignment;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.sql.ResultSet;
import java.util.Vector;

/**
     * @author 86132
     *
     */
    public class Y_J_orders extends JInternalFrame {
        private JTable table;

        /**
         * Launch the application.
         */
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    try {
                        Y_J_orders frame = new Y_J_orders();
                        frame.setVisible(true);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }

        /**
         * Create the frame.
         */
        public Y_J_orders() throws Exception {
            setMaximizable(true);
            setClosable(true);
            setBounds(100, 100, 974, 591);

            JScrollPane scrollPane = new JScrollPane();
            GroupLayout groupLayout = new GroupLayout(getContentPane());
            groupLayout.setHorizontalGroup(
                    groupLayout.createParallelGroup(Alignment.LEADING)
                            .addGroup(groupLayout.createSequentialGroup()
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 960, GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
            groupLayout.setVerticalGroup(
                    groupLayout.createParallelGroup(Alignment.LEADING)
                            .addGroup(groupLayout.createSequentialGroup()
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 559, GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );

            table = new JTable();
            table.setModel(new DefaultTableModel(
                    new Object[][] {
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                            {null, null, null, null, null},
                    },
                    new String[] {
                            "\u83DC\u54C1", "\u6570\u91CF", "\u91D1\u989D", "\u5E97\u5BB6", "\u63A5\u5355\u60C5\u51B5"
                    }
            ));
            scrollPane.setViewportView(table);
            getContentPane().setLayout(groupLayout);
            fill();
        }
        public void fill() throws Exception {
           ResultSet r= Y_J_orders_dao.filltable();
            DefaultTableModel model=(DefaultTableModel)table.getModel();
            model.setRowCount(0);
            while(r.next())
            {
                Vector v=new Vector();
                v.add(r.getString("dishename"));
                v.add(r.getString("num"));
                v.add(r.getString("money"));
                v.add(r.getString("business"));
                if(String_util.num(r.getString("bool_shop"))==2)
                {v.add("接单");}
                else v.add("退回");
                model.addRow(v);
            }

        }

    }
